import Page
from Page import Carpark
from Base.Base import Base
from selenium.webdriver.common.by import By


class CarparkAnimalRankingPage(Base):
    """
    车乐汇猜动物排行榜

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 返回按钮
        self.rank_close_btn = (By.XPATH, Carpark.RESOURCE_ID_Animal.format("iv_close"))

        # 用户头像
        self.rank_user_image_icon = (By.XPATH, Carpark.animal_user_image_icon.format(""))

        # 排名
        self.rank_user_ranking_text = (By.XPATH, Carpark.animal_user_ranking_text.format(""))

        # 账户名称
        self.rank_user_name_text = (By.XPATH, Carpark.animal_user_name_text.format(""))

        # 用户积分
        self.rank_user_integral_text = (By.XPATH, Carpark.animal_user_integral_icon.format(""))

    def click_close(self):
        """
         点击关闭按钮

         :return:None
         """
        self.click_element(self.rank_close_btn)

    def get_user_image(self, index=1):
        """
         获取用户头像

         :return:None
         """
        self.rank_user_image_icon = (By.XPATH, Carpark.dialect_user_image_icon.format(index))
        return self.find_element_o(self.rank_user_image_icon)

    def get_user_ranking(self, index=1):
        """
         获取用户排名

         :return:None
         """
        self.rank_user_ranking_text = (By.XPATH, Carpark.dialect_user_ranking_text.format(index))
        return self.find_element_o(self.rank_user_ranking_text)

    def get_user_name(self, index=1):
        """
         获取账户名称

         :return:None
         """
        self.rank_user_name_text = (By.XPATH, Carpark.dialect_user_name_text.format(index))
        return self.find_element_o(self.rank_user_name_text)

    def get_user_integral(self, index):
        """
         获取用户积分

         :return:None
         """
        self.rank_user_integral_text = (By.XPATH, Carpark.dialect_user_integral_icon.format(index))
        return self.find_element_o(self.rank_user_integral_text)

    def swipe_rank(self):
        """
        获取用户积分

        :return:None
        """
        self.swipe_o(location=(550, 550, 200, 550), direction='up')

    def is_display_carpark_rank(self):
        """
        查看是否进入猜方言排行榜页

        :return:
        """
        return self.is_display(self.rank_close_btn)
